package leetcode;

/**
 * @Project : AlgorithmLearning
 * @Package : Leetcode
 * @File : Q0455.java
 * @Author : WangRuoyu
 * @Date 2023/11/1 22:07
 */


public class Q0455 {
    public int findContentChildren(int[] g, int[] s) {
        int res = 0;
        java.util.Arrays.sort(g);
        java.util.Arrays.sort(s);

        for (int i = 0, j = 0; i < g.length && j < s.length; j++) {
            if (s[j] >= g[i]) {
                res++;
                i++;
            }
        }

        return res;
    }

    public static void main(String[] args) {
        Q0455 sl = new Q0455();
        int[] g = {1, 2};
        int[] s = {1, 2, 3};
        System.out.println(sl.findContentChildren(g, s));
    }
}